package com.liit.controller.weixin.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liit.entity.IntegralDetailFormMap;
import com.liit.mapper.IntegralDetailMapper;
import com.liit.plugin.PageView;
import com.liit.util.Common;

/**
 * 
 * @author dingweibo
 * @Title: UserIntegralController.java
 * @Description: 微信用户积分
 * @date 2016年3月31日
 */
@Controller
@RequestMapping("/weixin/user/")
public class UserIntegralController extends WeixinBaseController {

	@Resource
	IntegralDetailMapper mapper;

	@RequestMapping("integral/detail")
	public String integralDetail(Model model) throws Exception {
		model.addAttribute("weixinUser", getWeixinUserInfo());
		return Common.BACKGROUND_PATH + "/weixin/user/integralDetail";
	}

	@ResponseBody
	@RequestMapping("integral/findByPage")
	public PageView findByPage(String pageNow, String pageSize) throws Exception {
		IntegralDetailFormMap integralDetailFormMap = new IntegralDetailFormMap();
		integralDetailFormMap.put("openid", getOpenid());
		integralDetailFormMap.put("type", Common.INTEGRAL_TYPE_USER);
		integralDetailFormMap = toFormMap(integralDetailFormMap, pageNow, pageSize, " order by createTime desc ");
		pageView.setRecords(mapper.findByPage(integralDetailFormMap));
		return pageView;
	}
}